<?php
class Admin extends MX_Controller{
	function __construct(){
		parent::__construct();
	}
	
	function index(){
		if($this->session->userdata('Loggein')){
			header('Location:' . $this->config->item('base_url') . '/admin/dashboard');
		}
		$data = null;
		if($this->input->post()){
			$this->load->model('user');
			$data = $this->input->post();
			$CheckUser = $this->user->GetUserLogin($data['UserName'], $data['Password']);
			if(!$CheckUser){
				$data['Error'] = 'Incorrect Username or Password';
			} else {
				$CheckUser->Password = null;
				$this->session->set_userdata('Loggein', $CheckUser);
				header('Location:' . $this->config->item('base_url') . '/admin/dashboard');
			}
		}
		$this->load->view('login', $data);
	}
	
	function logout(){
		$this->session->sess_destroy();
		header('Location:' . $this->config->item('base_url') . '/admin');
	}
}
?>